# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>

pkgname=python-pycryptodome
pkgver=3.19.0
pkgrel=1
license=('BSD')
arch=('loong64' 'x86_64')
pkgdesc="Collection of cryptographic algorithms and protocols, implemented for use from Python 3."
url='https://www.pycryptodome.org/'
depends=('python' 'gmp')
makedepends=('gmp' 'python-'{build,installer,wheel} 'python-setuptools')
conflicts=('python-crypto')
provides=('python-crypto')
replaces=('python-crypto')
source=("pycryptodome-$pkgver.tar.gz::https://github.com/Legrandin/pycryptodome/archive/v$pkgver.tar.gz")
sha512sums=('1afa71336da38efb32f79d87b442a1d50537a6908ec153be7a087027a8540cebabab12922557c92e501f2d6da5c2f35466d3bbe6a3de44540de7278069691290')

build() {
  cd pycryptodome-$pkgver
  python -m build -wn

  cd test_vectors
  python -m build -wn
}

check() {
  cd pycryptodome-$pkgver
  python -m installer -d tmpinstall dist/*.whl
  python -m installer -d tmpinstall test_vectors/dist/*.whl
  PYTHONPATH="$PWD/tmpinstall/usr/lib/python3.11/site-packages" python -m Crypto.SelfTest
}

package() {
  cd pycryptodome-$pkgver
  python -m installer -d "$pkgdir" dist/*.whl
  install -Dm644 LICENSE.rst -t "$pkgdir"/usr/share/licenses/$pkgname/

  rm -r "$pkgdir"/usr/lib/python3.*/site-packages/Crypto/SelfTest/
}
